from Numbers import fib, gen_relatively_primes
import itertools
from fractions import Fraction
import math

#http://en.wikipedia.org/wiki/Fibonacci_number#Power_series
#http://www.cnd.mcgill.ca/~ivan/Fibonacci_power_series_3618079.pdf
fi = 1.61803398875
epsi = 0.000000001

def fib_sum(x):
    return x / (1 - x - x*x)

def gen_fractions(n):
    for d in range(max(1,int(n*(fi - epsi)) - 1), max(2,int(n*(fi + epsi)) + 1)):
        yield Fraction(n,d)

def test():
    visited = set()
    for n in range(1,10000000):
        for f in gen_fractions(n):
            fs = fib_sum(f)
            if fs > 0 and fs % 1 == 0:
                if fs not in visited:
                    print f, fs, float(f)
                    visited.add(fs)

test()


#1/2 2 - 1
#3/5 15 - 2
#8/13 104 - 3
#21/34 714 - 4
#55/89 4895 - 5
#144/233 33552 - 6
#377/610 229970 - 7
#987/1597 1576239 - 8
#2584/4181 10803704 - 9
#6765/10946 74049690   0.618033985017 - 10
#17711/28657 507544127 0.618033988205 - 11
#46368/75025 3478759200 0.61803398867 - 12
#121393/196418 23843770274 0.618033988738 - 13
#317811/514229 163427632719 0.618033988748 - 14
#832040/1346269 1120149658760 0.61803398875 - 15

